import 'dart:convert' show json;

import 'package:freedom/util/data_type.dart';

class MessageType {
  MessageType({
    this.type,
    this.msg,
  });

  factory MessageType.fromJson(Map<String, dynamic>? jsonRes) {
    if (jsonRes == null) {
      return MessageType();
    }
    return MessageType(
      type: asT<int>(jsonRes['type']),
      msg: asT<String>(jsonRes['msg']),
    );
  }

  int? type;
  String? msg;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'type': type,
        'msg': msg,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}
